package com.ruoyi.SSL.controller;

import java.util.List;

import com.ruoyi.SSL.domain.SslDomain;
import com.ruoyi.SSL.service.IAutoDeployService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.SSL.domain.SslCloudProductDeploy;
import com.ruoyi.SSL.service.ISslCloudProductDeployService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 云产品自动部署信息Controller
 *
 * @author ruoyi
 * @date 2024-12-12
 */
@Controller
@RequestMapping("/SSL/autoDeploy")
public class SslCloudProductDeployController extends BaseController
{
    private String prefix = "SSL/autoDeploy";

    @Autowired
    private ISslCloudProductDeployService sslCloudProductDeployService;

    @RequiresPermissions("SSL:autoDeploy:view")
    @GetMapping("/OSS")
    public String autoDeployOSS()
    {
        return prefix + "/autoDeployOSS";
    }

    @GetMapping("/CDN")
    public String autoDeployCDN()
    {
        return prefix + "/autoDeployCDN";
    }

    /**
     * 查询云产品自动部署信息列表
     */
    @RequiresPermissions("SSL:autoDeploy:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SslCloudProductDeploy sslCloudProductDeploy)
    {
        startPage();
        List<SslCloudProductDeploy> list = sslCloudProductDeployService.selectSslCloudProductDeployList(sslCloudProductDeploy);
        return getDataTable(list);
    }

    /**
     * 导出云产品自动部署信息列表
     */
    @RequiresPermissions("SSL:autoDeploy:export")
    @Log(title = "云产品自动部署信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SslCloudProductDeploy sslCloudProductDeploy)
    {
        List<SslCloudProductDeploy> list = sslCloudProductDeployService.selectSslCloudProductDeployList(sslCloudProductDeploy);
        ExcelUtil<SslCloudProductDeploy> util = new ExcelUtil<SslCloudProductDeploy>(SslCloudProductDeploy.class);
        return util.exportExcel(list, "云产品自动部署信息数据");
    }

    /**
     * 新增云产品自动部署信息
     */
    @GetMapping("/addCdn")
    public String addCdn()
    {
        return prefix + "/addCdn";
    }

    @GetMapping("/addOSS")
    public String addOSS(){
        return prefix + "/addOSS";
    }

    /**
     * 新增保存云产品自动部署信息
     */
    @RequiresPermissions("SSL:autoDeploy:add")
    @Log(title = "云产品自动部署信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SslCloudProductDeploy sslCloudProductDeploy)
    {
        return toAjax(sslCloudProductDeployService.insertSslCloudProductDeploy(sslCloudProductDeploy));
    }

    /**
     * 修改云产品自动部署信息
     */
    @RequiresPermissions("SSL:autoDeploy:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        SslCloudProductDeploy sslCloudProductDeploy = sslCloudProductDeployService.selectSslCloudProductDeployById(id);
        mmap.put("sslCloudProductDeploy", sslCloudProductDeploy);
        return prefix + "/edit";
    }

    /**
     * 修改保存云产品自动部署信息
     */
    @RequiresPermissions("SSL:autoDeploy:edit")
    @Log(title = "云产品自动部署信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SslCloudProductDeploy sslCloudProductDeploy)
    {
        return toAjax(sslCloudProductDeployService.updateSslCloudProductDeploy(sslCloudProductDeploy));
    }

    /**
     * 删除云产品自动部署信息
     */
    @RequiresPermissions("SSL:autoDeploy:remove")
    @Log(title = "云产品自动部署信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sslCloudProductDeployService.deleteSslCloudProductDeployByIds(ids));
    }

    @GetMapping("/setTime/{id}")
    public String setTime(@PathVariable("id") String id, ModelMap mmap){
        SslCloudProductDeploy sslCloudProductDeploy = sslCloudProductDeployService.selectSslCloudProductDeployById(id);
        mmap.put("sslCloudProductDeploy", sslCloudProductDeploy);
        return prefix + "/setTime";
    }


}
